namespace Agile.Genie.Descriptors
{
    using System.Data;

    /// <summary>
    /// Interface for stored procedure parameter details.
    /// </summary>
    /// <remarks>Implemented using the Strategy Pattern.</remarks>
    public class StoredProcedureParameter
    {
        /// <summary>
        /// The table column
        /// </summary>
        private TableColumn _column;

        /// <summary>
        /// The parameter direction
        /// </summary>
        private ParameterDirection _direction;

        /// <summary>
        /// Constructor
        /// </summary>
        protected StoredProcedureParameter(TableColumn column
                                           , ParameterDirection direction)
        {
            _column = column;
            _direction = direction;
        }
        /// <summary>
        /// Instantiate a new Stored procedure paramateter.
        /// </summary>
        /// <param name="column">The table column</param>
        /// <param name="direction">Direction of the parameter, 
        /// i.e. input/output</param>
        /// <returns></returns>
        public static StoredProcedureParameter Instantiate(TableColumn column, ParameterDirection direction)
        {
            StoredProcedureParameter parameter = new StoredProcedureParameter(column, direction);
            return parameter;
        }


        /// <summary>
        /// Gets the datatype of the column as it is defined in the database.
        /// </summary>
        public string DatabaseDataType
        {
            get { return Column.DataTypeFull; }
        }
        /// <summary>
        /// Gets the name of the parameter as it is likely to be used
        /// </summary>
        /// <remarks>Returns a safe/useable version of the name. E.g. 'a field name'
        /// would return 'afieldname'</remarks>
        public virtual string Name
        {
            get { return _column.NameSafe; }
        }

        /// <summary>
        /// Gets the exact name of the column, ie not formatted in any way.
        /// </summary>
        /// <remarks>E.g. 'a field name' would return 'a field name'</remarks>
        public virtual string ColumnName
        {
            get { return _column.Name; }
        }
        /// <summary>
        /// Gets the parameter direction of the column.
        /// </summary>
        public virtual string Direction
        {
            get { return _direction.ToString(); }
        }

        /// <summary>
        /// Gets the table column that the paramater is being created for.
        /// </summary>
        public TableColumn Column
        {
            get { return _column; }
        }


    }
}